package org.example.code.test2025.three_month;

import org.example.code.test2024.nine_mouth.A;

import java.util.*;
public class test0315 {
    public static void main(String[] args) {
        String ZH = "0大多数 1的 2纵向 3方法 4学家 5建议 6应 7不惜 8一切 9代价 10避免 11减员 。";
        String EN = "0Most 1longitudinal 2methodologists 3recommend 4that 5attrition 6should 7be 8avoided 9at 10all 11costs .";
        String id_map_of_cn2en = "0-0 2-1 2-2 3-2 4-2 5-3 5-4 6-6 6-7 7-8 8-10 9-9 9-11 10-8 11-5 12-12";
        test0315 t = new test0315();
        System.out.println(t.get_words_pair(ZH,EN,id_map_of_cn2en));
        /**
         * ["大多数","纵向 方法 学家","建议","应","不惜","一切","代价","避免","减员","。"],
         * ["Most","longitudinal methodologists","recommend that","should be","avoided","all","at costs","avoided","attrition","."]
         */
    }

    public String[][] get_words_pair (String ZH, String EN, String id_map_of_cn2en) {
        String[] str1 = ZH.split(" ");
        String[] str2 = EN.split(" ");
        String[] str3 = id_map_of_cn2en.split(" ");
        int n = str2.length;
        Map<Integer,List<String>> ENmap = new HashMap<>();
        Map<Integer,List<String>> ZHmap = new HashMap<>();
        for(int i=0;i<n;i++){
            int a = str3[i].charAt(0)-'0';
            int b = str3[i].charAt(2)-'0';
            ENmap.computeIfAbsent(a,k->new ArrayList<>()).add(str2[b]);
            ZHmap.computeIfAbsent(a,k->new ArrayList<>()).add(str1[a]);
        }
        return null;
    }

    private static int fun3(Map<Integer,List<int[]>> map, int n, int m) {
        int[] dp = new int[n+1];
        for(int i=0;i<=n;i++){
            dp[i]=-1;
        }
        dp[1]=0;
        for(int i=2;i<=n;i++){
            dp[i]=dp[i-1];
            if(map.containsKey(i)){
                for(int[] arr:map.get(i)){
                    int start = arr[0];
                    int bonus = arr[1];
                    if(dp[start]!=-1){
                        int result = bonus+dp[start];
                        dp[i]=Math.max(dp[i],result);
                    }
                }
            }
        }
        return dp[n];
    }

    private static int fun2(ArrayList<Integer>[] red, ArrayList<Integer>[] blue, int n, int m, int t) {
        int[][] dist = new int[n][2];
        for(int i=0;i<n;i++){
            for(int j=0;j<2;j++){
                dist[i][j]=Integer.MAX_VALUE;
            }
        }
        dist[0][0]=0;
        Queue<int[]> queue = new LinkedList<>();
        queue.offer(new int[]{0,0});
        while(!queue.isEmpty()){
            int[] cur = queue.poll();
            int c = cur[1];
            int u = cur[0];
            int temp = dist[u][c];
            if(u==t){
                return temp;
            }
            List<Integer> list;
            if(c==0){
                list=red[u];
            }else{
                list=blue[u];
            }
            for(int a :list){
                int cc = Math.abs(1-c);
                if(dist[a][cc]>temp){
                    dist[a][cc]=temp+1;
                    queue.offer(new int[]{a,cc});
                }
            }
        }
        return -1;
    }

    private static boolean fun(String str) {
        int n=str.length();
        if(n%2!=0){
            return false;
        }
        Map<Character,Character> map = new HashMap<>();
        map.put(')','(');
        map.put(']','[');
        map.put('}','{');
        Stack<Character> stack = new Stack<>();
        for(int i=0;i<n;i++){
            char c = str.charAt(i);
            if(c=='('||c=='['||c=='{'){
                stack.push(c);
            }else{
                if(stack.isEmpty()){
                    return false;
                }
                char t = stack.pop();
                if(t!=map.get(c)){
                    return false;
                }
            }
        }
        return stack.isEmpty();
    }
}
